package tan.reporting.ui {

import flash.display.DisplayObjectContainer;

import org.robotlegs.mvcs.Context;

import tan.reporting.ui.commands.IncreaseCountCommand;
import tan.reporting.ui.events.IncreaseCountEvent;
import tan.reporting.ui.model.MenuClickModel;
import tan.reporting.ui.view.mediators.MainMediator;

public class ApplicationContext extends Context {

    public function ApplicationContext(contextView:DisplayObjectContainer=null) {
        super(contextView);
    }

    override public function startup():void {
        prepModels();
        prepControllers();
        prepServices();
        prepViews();

        super.startup();
    }

    protected function prepModels():void {
        injector.mapSingleton(MenuClickModel);
    }

    protected function prepControllers():void {
        commandMap.mapEvent(IncreaseCountEvent.INCREASE, IncreaseCountCommand, IncreaseCountEvent);
    }

    protected function prepServices():void {
        //injector.mapSingletonOf()
    }

    protected function prepViews():void {
        mediatorMap.mapView(Main, MainMediator);
    }

    override public function shutdown():void {
        injector.unmap(MenuClickModel);
        commandMap.unmapEvent(IncreaseCountEvent.INCREASE, IncreaseCountCommand, IncreaseCountEvent);
        mediatorMap.unmapView(Main);

        super.shutdown();
    }
}

}